package com.wondertek.poms.common.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class LocalDateTimeUtils {


	/**
	 * <p><b>Title:</b> date2LocalDateTime</p>
	 * <p><b>Description:</b> date2LocalDateTime</p>
	 * @author douzi
	 * @param date
	 * @return
	 */
	public static LocalDateTime date2LocalDateTime(Date date) {
    	if (date == null) {
    		return null;
    	}
    	
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        return instant.atZone(zoneId).toLocalDateTime();
    }



	/**
	 * 按指定格式对LocalDateTime类型进行格式化输出（返回类型：String）
	 *
	 * @param date
	 * @param format
	 * @return
	 */
	public static String localDateFormat(LocalDateTime date, String format) {
		DateTimeFormatter formatDate = DateTimeFormatter.ofPattern(format);
		return date.format(formatDate);
	}


}
